home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue34 / construc / IntraBob / DEBUG.DPR < prev    next >
Encoding:
Text File  |  1998-05-11  |  4.3 KB  |  108 lines

  1. library DEBUG;
  2. {
  3.   This example ISAPI.DLL library DEBUG is part of IntraBob version 3.0, and
  4.   can be used to demostrate how to Test/Debug ISAPI.DLLs on a local machine
  5.   (i.e. without the need for a Web Server).
  6.  
  7.   Steps:
  8.   1. Start Delphi 3
  9.   2. Load DEBUG.DPR (this file)
  10.   3. Specify "INTRABOB.EXE" as Hosting Application (Run | Parameters)
  11.   4. Run the DLL, which starts IntraBob
  12.   5. Click on the "submit" button to load the DEBUG ISAPI.DLL
  13.   6. Don't forget to close IntraBob to return to the Delphi 3 IDE
  14.  
  15.   Feedback is welcome in news://news.shoresoft.com/drbob.internet.tools,
  16.   or by e-mail to bob@bolesian.nl
  17. }
  18. uses
  19.   Windows, SysUtils, ISAPI;
  20.  
  21.   function GetExtensionVersion(var Ver: THSE_VERSION_INFO): BOOL; stdcall;
  22.   begin
  23.     Ver.dwExtensionVersion := $00010000;  // 1.0 support
  24.     Ver.lpszExtensionDesc := 'Delphi 3.0 ISAPI DLL'; // Description
  25.     Result := True;
  26.   end;
  27.  
  28.   function HttpExtensionProc(var ECB: TEXTENSION_CONTROL_BLOCK): DWORD; stdcall;
  29.   const
  30.     MaxBuf = 1024;
  31.   var
  32.     Buffer: Array[0..MaxBuf] of Char;
  33.     Size: Integer;
  34.     Str: String;
  35.   begin
  36.     ECB.lpszLogData := 'Bob Swart (aka Dr.Bob - www.drbob42.com)';
  37.     ECB.dwHTTPStatusCode := 200;
  38.     Str :=
  39.       '<HTML>'#13#10 +
  40.       '<HEAD>'#13#10 +
  41.       '<TITLE>Dr.Bob''s ISAPI Debugger</TITLE>'#13#10 +
  42.       '</HEAD>'#13#10 +
  43.       '<BODY BGCOLOR=A7B7C7>'#13#10 +
  44.       '<H1>Dr.Bob''s ISAPI Debugger</H1>'#13#10 +
  45.       '<HR>'#13#10 +
  46.       '<H3>Server Variables</H3>'#13#10 +
  47.       '<UL>'#13#10;
  48.     Size := MaxBuf;
  49.     if ECB.GetServerVariable(ECB.ConnID,'SERVER_SOFTWARE', @Buffer, Size) then
  50.       Str := Str + '<LI><B>SERVER_SOFTWARE:</B>'#13'<BR>' + StrPas(Buffer) + #13#10;
  51.     Size := MaxBuf;
  52.     if ECB.GetServerVariable(ECB.ConnID,'REQUEST_METHOD', @Buffer, Size) then
  53.       Str := Str + '<LI><B>REQUEST_METHOD:</B>'#13'<BR>' + StrPas(Buffer) + #13#10;
  54.     Size := MaxBuf;
  55.     if ECB.GetServerVariable(ECB.ConnID,'CONTENT_LENGTH', @Buffer, Size) then
  56.       Str := Str + '<LI><B>CONTENT_LENGTH:</B>'#13'<BR>' + StrPas(Buffer) + #13#10;
  57.     Size := MaxBuf;
  58.     if ECB.GetServerVariable(ECB.ConnID,'CONTENT_TYPE', @Buffer, Size) then
  59.       Str := Str + '<LI><B>CONTENT_TYPE:</B>'#13'<BR>' + StrPas(Buffer) + #13#10;
  60.     Size := MaxBuf;
  61.     if ECB.GetServerVariable(ECB.ConnID,'QUERY_STRING', @Buffer, Size) then
  62.       Str := Str + '<LI><B>QUERY_STRING:</B>'#13'<BR>' + StrPas(Buffer) + #13#10;
  63.     Size := MaxBuf;
  64.     if ECB.GetServerVariable(ECB.ConnID,'PATH_INFO', @Buffer, Size) then
  65.       Str := Str + '<LI><B>PATH_INFO:</B>'#13'<BR>' + StrPas(Buffer) + #13#10;
  66.     Size := MaxBuf;
  67.     if ECB.GetServerVariable(ECB.ConnID,'URL', @Buffer, Size) then
  68.       Str := Str + '<LI><B>URL:</B>'#13'<BR>' + StrPas(Buffer) + #13#10;
  69.     Str := Str +
  70.       '</UL>'#13#10 +
  71.       '<HR>'#13#10 +
  72.       '<H3>ECB Data:</H3>'#13#10 +
  73.       '<UL>'#13#10 +
  74.       '<LI><B>ECB.cbSize:</B>'#13'<BR>' + IntToStr(ECB.cbSize) + #13#10 +
  75.       '<LI><B>ECB.dwVersion:</B>'#13'<BR>' + IntToStr(ECB.dwVersion) + #13#10 +
  76.       '<LI><B>ECB.ConnID:</B>'#13'<BR>' + IntToStr(ECB.ConnID) + #13#10 +
  77.       '<LI><B>ECB.lpszMethod:</B>'#13'<BR>' + ECB.lpszMethod + #13#10 +
  78.       '<LI><B>ECB.lpszQueryString:</B>'#13'<BR>' + ECB.lpszQueryString + #13#10 +
  79.       '<LI><B>ECB.lpszPathInfo:</B>'#13'<BR>' + ECB.lpszPathInfo + #13#10 +
  80.       '<LI><B>ECB.lpszPathTranslated:</B>'#13'<BR>' + ECB.lpszPathTranslated + #13#10 +
  81.       '<LI><B>ECB.cbTotalBytes:</B>'#13'<BR>' + IntToStr(ECB.cbTotalBytes) + #13#10 +
  82.       '<LI><B>ECB.cbAvailable:</B>'#13'<BR>' + IntToStr(ECB.cbAvailable) + #13#10 +
  83.       '<LI><B>ECB.lpszContentType:</B>'#13'<BR>' + ECB.lpszContentType + #13#10 +
  84.       '<LI><B>ECB.lpbData:</B>'#13'<BR>' + StrPas(ECB.lpbData) + #13#10 +
  85.       '</UL>'#13#10 +
  86.       '<HR>'#13#10 +
  87.       'See also: <A HREF="http://www.drbob42.com">Dr.Bob''s Delphi Clinic</A>' +
  88.       '</BODY>'#13#10 +
  89.       '</HTML>'#13#10;
  90.  
  91.     Str := Format(
  92.       'HTTP/1.0 200 OK'#13#10+
  93.       'Content-Type: text/html'#13#10+
  94.       'Content-Length: %d'#13#10+
  95.       'Content:'#13#10#13#10'%s', [Length(Str), Str]);
  96.  
  97.     Size := Length(Str);
  98.     ECB.WriteClient(ECB.ConnID, Pointer(Str), Size, 0);
  99.     Result := HSE_STATUS_SUCCESS
  100.   end;
  101.  
  102. exports
  103.   GetExtensionVersion,
  104.   HttpExtensionProc;
  105.  
  106. begin
  107. end.
  108.